package DataAccess.Storage;

import java.io.Serializable;
import DistSys.*;

/**
 * Title:        iPAD
 * Description:
 * Copyright:    Copyright (c) 2002
 * Company:      ABB Inc.
 * @author Fangxing Li
 * @version 1.0
 */

public class PrjMiscForStorage implements Serializable{
  public static final long serialVersionUID=100200L;

  protected String  sVersion;

  protected int     iActiveShadingCat;

  protected int     iShowLegend;
  protected int     iShowScale;
  protected int     iShowGridLine;
  protected int     iShowNodes;
  protected int     iDrawText;
  protected int     iFreeze;

  protected int     iHighLightOpenPoints;
  protected int     iHighLightSect;
  protected int     iHighLightSelected;

  protected double  dZoomFactor;
  protected double  dZoomFactorPrev;

  protected double  dLengthPerUnit;
  protected int     iUnitOfLength;
  protected double  dGridWidth; //in virtual resolution

  public PrjMiscForStorage() { }

  public void copyFromSysInMem( ){
      this.sVersion = Sys.prjInfo.sVersion;
      this.iActiveShadingCat = Sys.prjInfo.shadingCat;
      if( Sys.prjInfo.showLegend )    { this.iShowLegend = 1; }
      else                            { this.iShowLegend = 0; }
      if( Sys.prjInfo.showScale )     { this.iShowScale = 1; }
      else                            { this.iShowScale = 0; }
      if( Sys.prjInfo.showGridLine )  { this.iShowGridLine = 1; }
      else                            { this.iShowGridLine = 0; }
      if( Sys.prjInfo.showNodes )     { this.iShowNodes = 1; }
      else                            { this.iShowNodes = 0; }
      if( Sys.prjInfo.drawText)       { this.iDrawText = 1; }
      else                            { this.iDrawText = 0; }
      if( Sys.prjInfo.freeze )        { this.iFreeze = 1; }
      else                            { this.iFreeze = 0; }
      if( Sys.prjInfo.isHighLightOpenPoints ) { this.iHighLightOpenPoints =1; }
      else                                    { this.iHighLightOpenPoints =0; }
      if( Sys.prjInfo.isHighLightSect )       { this.iHighLightSect = 1; }
      else                                    { this.iHighLightSect = 0; }
      if( Sys.prjInfo.isHighLightSelected )   { this.iHighLightSelected = 1; }
      else                                    { this.iHighLightSelected = 0; }
      this.dLengthPerUnit = Sys.prjInfo.lengthPerUnit;
      this.iUnitOfLength = Sys.prjInfo.unitOfLength;
      this.dGridWidth = Sys.prjInfo.gridWidth;
  }

  public void copyToSysInMem( ){
      Sys.prjInfo.sVersion = this.sVersion;
      Sys.prjInfo.shadingCat = this.iActiveShadingCat;
      if( this.iShowLegend==0 )   { Sys.prjInfo.showLegend = false; }
      else                        { Sys.prjInfo.showLegend = true; }
      if( this.iShowScale==0 )    { Sys.prjInfo.showScale = false; }
      else                        { Sys.prjInfo.showScale = true; }
      if( this.iShowGridLine==0 ) { Sys.prjInfo.showGridLine = false; }
      else                        { Sys.prjInfo.showGridLine = true; }
      if( this.iShowNodes==0 )    { Sys.prjInfo.showNodes = false; }
      else                        { Sys.prjInfo.showNodes = true; }
      if( this.iDrawText==0 )     { Sys.prjInfo.drawText = false; }
      else                        { Sys.prjInfo.drawText = true; }
      if( this.iFreeze==0 )       { Sys.prjInfo.freeze = false; }
      else                        { Sys.prjInfo.freeze = true; }
      if( this.iHighLightOpenPoints==0) { Sys.prjInfo.isHighLightOpenPoints = false; }
      else                              { Sys.prjInfo.isHighLightOpenPoints = true; }
      if( this.iHighLightSect==0)       { Sys.prjInfo.isHighLightSect = false; }
      else                              { Sys.prjInfo.isHighLightSect = true; }
      if( this.iHighLightSelected==0)   { Sys.prjInfo.isHighLightSelected = false; }
      else                              { Sys.prjInfo.isHighLightSelected = true; }
      Sys.prjInfo.lengthPerUnit = this.dLengthPerUnit;
      Sys.prjInfo.unitOfLength = this.iUnitOfLength;
      Sys.prjInfo.gridWidth = this.dGridWidth;
  }

  public int getUnitOfLength(){ return this.iUnitOfLength; }
}